import { getMemberList, getMemberDetail } from '@/api/party-member'

const state = {
  list: [],
  total: 0,
  currentMember: null
}

const mutations = {
  SET_LIST: (state, { items, total }) => {
    state.list = items
    state.total = total
  },
  SET_CURRENT_MEMBER: (state, member) => {
    state.currentMember = member
  }
}

const actions = {
  async getList({ commit }, query) {
    const { data } = await getMemberList(query)
    commit('SET_LIST', data)
    return data
  },
  async getMemberDetail({ commit }, id) {
    const { data } = await getMemberDetail(id)
    commit('SET_CURRENT_MEMBER', data)
    return data
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
} 